/*
 * =====================================================================================
 *
 *       Filename:  point.h
 *
 *    Description:  point
 *
 *        Version:  1.0
 *        Created:  2009年06月08日 19时09分21秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Ying Wang (WY), ywang@nlpr.ia.ac.cn
 *        Company:  Institute of Automation, Chinese Academy of Sciences
 *
 * =====================================================================================
 */

#ifndef POINT_H
#define POINT_H
#include <iostream>
template<typename T>
class NCpoint
{
	template<typename T1>
		friend std::ostream& operator << (std::ostream& os, const NCpoint<T1>& point);
	template<typename T1>
		friend bool operator == ( const NCpoint<T1> &p1, const NCpoint<T1> &p2);
	template<typename T1>
		friend bool operator != ( const NCpoint<T1> &p1, const NCpoint<T1> &P2);
public:
	NCpoint();
	NCpoint(const T &x, const T &y);
	NCpoint(const NCpoint<T> &point);

	inline NCpoint<T>& operator = (const NCpoint<T> &point);

public:
	inline T x() const {return m_x;}
	inline T y() const {return m_y;}
public:
	inline void setX(const T &x) {m_x = x;}
	inline void setY(const T &y) {m_y = y;}
private:
	T m_x;
	T m_y;
};

template<typename T>
NCpoint<T> :: NCpoint ()
	: m_x(0)
	, m_y(0)
{

}

template<typename T>
NCpoint<T> :: NCpoint ( const T &x, const T &y )
	: m_x(x)
	, m_y(y)
{

}

template<typename T>
NCpoint<T> :: NCpoint ( const NCpoint<T> &point )
	: m_x(point.m_x)
	, m_y(point.m_y)
{

}

template<typename T>
inline NCpoint<T>& NCpoint<T> :: operator = ( const NCpoint<T> &point)
{
	if( this != &point )
	{
		m_x = point.m_x;
		m_y = point.m_y;
	}
	return *this;
}

template<typename T1>
bool operator == ( const NCpoint<T1> &p1, const NCpoint<T1> &p2)
{
	return (p1.m_x == p2.m_x) && (p1.m_y == p2.m_y);
}
template<typename T1>
bool operator != ( const NCpoint<T1> &p1, const NCpoint<T1> &p2)
{
	return (p1.m_x != p2.m_x) || (p1.m_y != p2.m_y);
}

template<typename T1>
std::ostream& operator << (std::ostream& os, const NCpoint<T1>& point)
{
	os<<point.m_x<<" "<<point.m_y;
	return os;
}
#endif
